package cn.github.util;

import java.io.Serializable;

/*
 *
 * PageInfo
 * @author wangwei
 * @date 2019/1/9
 * @param null
 * @return
 */
public class myPageInfo implements Serializable {


    private static final long serialVersionUID = 1L;
    /**
     * 总记录数
     */
    private Long total;
    /**
     * 总页数
     */
    private Long totalPages;
    /**
     * 当前页
     */
    private Integer pageNo;
    /**
     * 页记录数
     */
    private Integer pageSize;

    public myPageInfo(Long total) {
        this.total = total;
    }

    public myPageInfo(Long total, Integer pageNo,
                      Integer pageSize) {
        this.total = total;
        this.totalPages = (total - 1) / pageSize + 1;
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    public static myPageInfo page(Long total) {
        return new myPageInfo(total);
    }

    public static myPageInfo page(Long total, Integer pageNo,
                                  Integer pageSize) {
        return new myPageInfo(total, pageNo, pageSize);
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Long getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Long totalPages) {
        this.totalPages = totalPages;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

}
